// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.

#ifndef CERBERUS_PROTOCOL_OBSERVER_H_
#define CERBERUS_PROTOCOL_OBSERVER_H_

#include "status/rot_status.h"
#include "cmd_interface.h"


/**
 * Interface for notifying observers of Cerberus protocol responses.  Unwanted event notifications will be set to
 * null.
 */
struct cerberus_protocol_observer {
	/**
	 * Notification that a get digest response message has been received. 
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 * @param reponse The response container received.
	 */
	void (*on_get_digest_response) (struct cerberus_protocol_observer *observer, 
		struct cmd_interface_msg *response);

	/**
	 * Notification that a get certificate response message has been received.  
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 * @param reponse The response container received.
	 */
	void (*on_get_certificate_response) (struct cerberus_protocol_observer *observer, 
		struct cmd_interface_msg *response);

	/**
	 * Notification a challenge response message has been received. 
	 *
	 * Arguments passed with the notification will never be null.
	 *
	 * @param observer The observer instance being notified.
	 * @param reponse The response container received.
	 */
	void (*on_challenge_response) (struct cerberus_protocol_observer *observer, 
		struct cmd_interface_msg *response);
};


#define	CERBERUS_PROTOCOL_OBSERVER_ERROR(code)		ROT_ERROR (ROT_MODULE_CERBERUS_PROTOCOL_OBSERVER, code)

/**
 * Error codes that can be generated by a Cerberus protocol observer.
 */
enum {
	CERBERUS_PROTOCOL_OBSERVER_INVALID_ARGUMENT = CERBERUS_PROTOCOL_OBSERVER_ERROR (0x00),		/**< Input parameter is null or not valid. */
	CERBERUS_PROTOCOL_OBSERVER_NO_MEMORY = CERBERUS_PROTOCOL_OBSERVER_ERROR (0x01),				/**< Memory allocation failed. */
};


#endif /* CERBERUS_PROTOCOL_OBSERVER_H_ */
